package com.example.springbootvue.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户实体类
 */
@Data
@TableName("\"user\"")
public class User implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户名
     */
    @NotBlank
    @Size(max = 20)
    @TableField(value = "username", condition = "%s = #{%s}")
    private String username;

    /**
     * 密码
     */
    @NotBlank
    @Size(max = 100)
    private String password;

    /**
     * 邮箱
     */
    @NotBlank
    @Size(max = 50)
    @Email
    @TableField(value = "email", condition = "%s = #{%s}")
    private String email;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 用户状态: 0-禁用, 1-正常
     */
    private Integer status = 1;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 逻辑删除标识: 1-已删除, 0-未删除
     */
    @TableLogic
    private Integer deleted = 0;
}